Kubernetes for Jobseekers by Gopalakrishnan Shivakumar;

Kubernetes for Jobseekers by Gopalakrishnan Shivakumar;

Author:Gopalakrishnan, Shivakumar; [Gopalakrishnan, Shivakumar]
Language: eng
Format: epub
Publisher: BPB Publications
Published: 2023-03-15T00:00:00+00:00


Higher availability with stable software is possible, if not for the pesky developers who want to achieve value to the customers in bug fixes and new features 😊.

Blue-green deployment

For a detailed look into blue-green deployment, see https://codefresh.io/blue-green-deployments-kubernetes/. A typical blue-green deployment diagram:

Figure 7.2: Blue-green deployments

Try it

Launch the blue version by running the following:

kubectl apply -f chap-7-blue-deployment-defn.yaml

The spec has a version label to denote whether it is blue or green:

Selector:

matchLabels:

app: frontend

version: blue

Launch the service frontend with a selector to match the version: blue:

kubectl apply -f chap-7-blue-svc-defn.yaml

spec:

selector:

app: frontend

version: blue

Verify that the app works:

$ kubectl get svc

NAME TYPE CLUSTER-IP EXTERNAL-IP PORT(S) AGE

frontend NodePort 10.110.95.223 <none> 8080:32575/TCP 34h

$ curl localhost:32575

<!DOCTYPE html>

…

Let us intentionally launch a green version that we know will fail:

Kubectl apply -f chap-7-fail-green-deployment.yaml

The spec has the version label set to green:

Selector:

matchLabels:

app: frontend

version: green

As expected, the pods are not marked as READY:

Kubectl get pods

NAME READY STATUS RESTARTS AGE

nginx-blue-deployment-5778cb9488-4ssqj 1/1 Running 0 30s

nginx-blue-deployment-5778cb9488-68zwm 1/1 Running 0 30s

nginx-blue-deployment-5778cb9488-pf5tj 1/1 Running 0 30s

nginx-fail-green-deployment-db478459d-jfbqs 0/1 Running 0 6s

You can verify that the app still works by running curl localhost:<your service NodePort>. To ensure that the deployment is bad, let us ask the service to direct the traffic to the bad Pods:

Kubectl apply -f chap-7-green-svc-defn.yaml

Verify that the app does not work by running curl localhost:<your service NodePort>:

curl localhost:32575

curl: (52) Empty reply from server

You can see the benefit of the blue-green deployment. Even though we switched to the green deployment by mistake, we can quickly change it back to blue since we have not deleted the blue deployment:

Kubectl apply -f chap-7-blue-svc-defn.yaml



Download



Copyright Disclaimer:
This site does not store any files on its server. We only index and link to content provided by other sites. Please contact the content providers to delete copyright contents if any and email us, we'll remove relevant links or contents immediately.